﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class SupportManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            load_AllSupport();
        }
    }

    public void load_AllSupport()
    {
        SupportRepeater.DataSource = BusLogic.Support.get_ALL_SUPPORT();
        SupportRepeater.DataBind();
    }

    protected void cbxCheckALLSupport_CheckedChanged(object sender, EventArgs e)
    {
        if (cbxCheckALLSupport.Checked == true)
        {
            foreach (RepeaterItem item in SupportRepeater.Items)
            {
                CheckBox cbxCheckSupport = item.FindControl("cbxCheckSupport") as CheckBox;
                cbxCheckSupport.Checked = true;
            }
        }
        else
        {
            foreach (RepeaterItem item in SupportRepeater.Items)
            {
                CheckBox cbxCheckSupport = item.FindControl("cbxCheckSupport") as CheckBox;
                cbxCheckSupport.Checked = false;
            }
        }
    }

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in SupportRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckSupport");

            if (cb.Checked == true)
            {
                TextBox txtSupportId = (TextBox)item.FindControl("txtSupportId");
                BusLogic.Support.remove_SUPPORT(int.Parse(txtSupportId.Text));
            }
        }

        load_AllSupport();        
        cbxCheckALLSupport.Checked = false;
    }
}
